package com.csair.seam.infrastructure.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.csair.seam.infrastructure.web.interceptor.AdminAuthInterceptor;
import com.csair.seam.infrastructure.web.interceptor.JWTInterceptor;
/**
 * @Author: wurunbin
 * @Date: 2020/3/5 15:20
 * @Description: 增加拦截器
 **/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private AdminAuthInterceptor adminAuthInterceptor;
    
    @Autowired
    private JWTInterceptor jwtInterceptor;
    
    @Value("${spring.resources.static-locations}")
	private String staticLocation;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    	registry.addInterceptor(adminAuthInterceptor).addPathPatterns("/pc/statistics/**","/pc/visits/**","/pc/fa/**","/pc/idleReceive/**");
    	registry.addInterceptor(jwtInterceptor).addPathPatterns("/mobile/**");
    }
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    	registry.addResourceHandler("/images/**").addResourceLocations(staticLocation);
    }
}
